
package com.kanjian.music.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.JsonSyntaxException;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.kanjian.music.KanjianApplication;

public class Banner extends BaseCode implements Serializable {
    
    public static final String BANNER_TYPE_USER = "user";
    
    public static final String BANNER_TYPE_SONG = "song";
    
    private static final long serialVersionUID = 1L;

    @SerializedName("URL")
    public String mUrl;

    @SerializedName("mid")
    public int mMusicId;

    @SerializedName("pic_url")
    public String mPicUrl;

    @SerializedName("uid")
    public int mUserId;
    
    @SerializedName("level")
    public int mLevel;
    
    @SerializedName("theId")
    public int mTheId;
    
    @SerializedName("banner_type")
    public String mBannerType;

    public static ArrayList<Banner> getBannerListFromJson(String json) {
        JSONObject jobj = getJSONObjectFromString(json);
        if (jobj != null) {
            try {
                return KanjianApplication.GSON.fromJson(jobj.getJSONArray("banner").toString(),
                        new TypeToken<List<Banner>>() {
                        }.getType());
            } catch (JsonSyntaxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }

}
